package com.example.stuwork.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 作业实体类
 * 对应 assignment 表
 */
public class Assignment implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 作业ID
     */
    private Long assignmentId;

    /**
     * 课程编码
     */
    private String courseId;

    /**
     * 班级ID
     */
    private Long classId;

    /**
     * 发布教师工号
     */
    private String teacherId;

    /**
     * 作业标题
     */
    private String title;

    /**
     * 作业描述
     */
    private String description;

    /**
     * 资源URL
     */
    private String resourceUrl;

    /**
     * 提交截止时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deadline;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    /**
     * 学生提交状态（非数据库字段，由API查询填充）
     * 0：未提交
     * 1：已提交
     * 2：已批改
     * 3：已逾期
     */
    private Integer status;

    /**
     * 学生得分（非数据库字段，由API查询填充）
     */
    private Integer score;

    /**
     * 无参构造函数
     */
    public Assignment() {
    }

    /**
     * 全参构造函数
     */
    public Assignment(Long assignmentId, String courseId, Long classId, String teacherId, String title,
                     String description, String resourceUrl, Date deadline, Date createTime, Date updateTime) {
        this.assignmentId = assignmentId;
        this.courseId = courseId;
        this.classId = classId;
        this.teacherId = teacherId;
        this.title = title;
        this.description = description;
        this.resourceUrl = resourceUrl;
        this.deadline = deadline;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    /**
     * 用于创建作业的构造函数
     */
    public Assignment(String courseId, Long classId, String teacherId, String title,
                     String description, String resourceUrl, Date deadline) {
        this.courseId = courseId;
        this.classId = classId;
        this.teacherId = teacherId;
        this.title = title;
        this.description = description;
        this.resourceUrl = resourceUrl;
        this.deadline = deadline;
    }

    // Getters and Setters
    public Long getAssignmentId() {
        return assignmentId;
    }

    public void setAssignmentId(Long assignmentId) {
        this.assignmentId = assignmentId;
    }

    public String getCourseId() {
        return courseId;
    }

    public void setCourseId(String courseId) {
        this.courseId = courseId;
    }

    public Long getClassId() {
        return classId;
    }

    public void setClassId(Long classId) {
        this.classId = classId;
    }

    public String getTeacherId() {
        return teacherId;
    }

    public void setTeacherId(String teacherId) {
        this.teacherId = teacherId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getResourceUrl() {
        return resourceUrl;
    }

    public void setResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
    }

    public Date getDeadline() {
        return deadline;
    }

    public void setDeadline(Date deadline) {
        this.deadline = deadline;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Integer getScore() {
        return score;
    }

    public void setScore(Integer score) {
        this.score = score;
    }

    @Override
    public String toString() {
        return "Assignment{" +
                "assignmentId=" + assignmentId +
                ", courseId='" + courseId + '\'' +
                ", classId=" + classId +
                ", teacherId='" + teacherId + '\'' +
                ", title='" + title + '\'' +
                ", description='" + description + '\'' +
                ", resourceUrl='" + resourceUrl + '\'' +
                ", deadline=" + deadline +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", status=" + status +
                ", score=" + score +
                '}';
    }
} 